﻿using System.Web.Http;
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using OSharp.Autofac.Http;
using OSharp.Autofac.Mvc;
using OSharp.Core;
using OSharp.Core.Caching;
using OSharp.Core.Dependency;
using OSharp.Logging.Log4Net;
using OSharp.Web.Mvc.Routing;
using OSharp.Web.Http.Extensions;

namespace Serenity.Libra.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            //AreaRegistration.RegisterAllAreas();
            RoutesRegister();

            //JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            //{
            //    Formatting = Newtonsoft.Json.Formatting.Indented,
            //    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            //};
        }
        private static void RoutesRegister()
        {
            GlobalConfiguration.Configuration.MapDefaultRoutes();

            RouteCollection routes = RouteTable.Routes;
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapLowerCaseUrlRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new[] { "Serenity.Libra.Web.Controllers" });
        }
    }
}
